package cool.qingqing.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * @author 高山青
 * @Date 2021/12/26  -   19:38
 */
@Component
@Slf4j
public class MyMetaObjectHandler implements MetaObjectHandler {
	@Override
	public void insertFill(MetaObject metaObject) {
		log.info("start insert field....");
		this.setFieldValByName("addData", LocalDate.now(),metaObject);
		this.setFieldValByName("updateData", LocalDate.now(),metaObject);
	}

	@Override
	public void updateFill(MetaObject metaObject) {
		this.setFieldValByName("updateData", LocalDate.now(),metaObject);
	}
}

